const path = require("path")
const ip = require("ip")
module.exports = app => {
    const exports = {}

    exports.view = {
        cache: false
    }

    exports.static = {
        maxAge: 0 // maxAge 缓存，默认 1 年
    }
    // 存放一些公用资源的
    exports.htmlTemplate = {
        js: [
            `/static/js/vue.js`,
            "//cdn.bootcss.com/vue/2.6.11/vue.runtime.js",
            `/static/js/element-ui.js`,
            `/static/js/vue-router.js`,
            `/static/js/vuex.js`,
            `/static/js/axios.js`
        ]
    }

    exports.development = {
        watchDirs: ["app/view"], // 指定监视的目录（包括子目录），当目录下的文件变化的时候自动重载应用，路径从项目根目录开始写
        ignoreDirs: ["web", "public", "config/manifest.json"] // 指定过滤的目录（包括子目录）
    }

    exports.logview = {
        dir: path.join(app.baseDir, "logs")
    }

    exports.vuessr = {
        injectCss: true
    }

    exports.webpack = {
        webpackConfigList: require("easywebpack-vue").getWebpackConfig()
    }

    const localIP = ip.address()
    const domainWhiteList = [];
    [7001, 9000, 9001].forEach(port => {
        domainWhiteList.push(`http://localhost:${port}`)
        domainWhiteList.push(`http://127.0.0.1:${port}`)
        domainWhiteList.push(`http://${localIP}:${port}`)
    })

    exports.security = {domainWhiteList}

    return exports
}
